package com.teach;

/**
 * <pre>
 * -
 * Author : J.L.Zhou
 * E-Mail : 2233875735@qq.com
 * Tel : 151 1104 7708
 * Date : 2021-04-12 16:23
 * Version : 1.0
 * Copyright 2021 jlzhou.top Inc. All rights reserved.
 * Warning: this content is only for internal circulation of the company.
 *          It is forbidden to divulge it or use it for other commercial purposes.
 * </pre>
 **/
public class Demo05 {

  public static void main(String[] args) {
    String str1 = " \tabc \tabc \t";
    System.out.println("|"+str1+"|");
    str1 = str1.trim();
    System.out.println("|"+str1+"|");

    str1 = " \tabc \tabc　\t";//不含中文全角空格的
    System.out.println("|"+str1+"|");
    str1 = str1.trim();
    System.out.println("|"+str1+"|");

    //js:leftTrim() rightTrim();//在java中不存在去只有空格的方法

    str1 = " \tabc \tabc \tcba ";
    System.out.println("|"+str1+"|");
    String str2 = str1.replace('a','A');
    System.out.println("|"+str2+"|");
    str2 = str1.replace("ab","AB");
    System.out.println("|"+str2+"|");

    str2 = str1.replaceFirst("ab","AB");
    System.out.println("|"+str2+"|");

    str2 = str1.replaceAll("ab","AB");
    System.out.println("|"+str2+"|");

    str2 = str1.replaceAll("[a-z][a-z]","AB");
    System.out.println("|"+str2+"|");
    str2 = str1.replaceAll("([a-z])([a-z])([a-z])","$2$3o$1");
    System.out.println("|"+str2+"|");

    str2 = str1.replaceAll("^\\s+","");
    System.out.println("|"+str2+"|");
    str2 = str1.replaceAll("\\s+$","");
    System.out.println("|"+str2+"|");




  }
}
